import { defineStore } from 'pinia'
import { ref } from 'vue'

/**
 * 此状态树的数据仅共享给track组件的子级组件使用，不能将此状态树数据共享给
 */

export const useTrackStore = defineStore('trackStore', () => {
  const loading = ref(false)
  const positionSet = ref<any[]>([])
  const stopSet = ref<any[]>([])
  const tripSet = ref<any[]>([])

  function setRecord({positions, stops, trips}){
    positionSet.value = positions
    stopSet.value = stops
    tripSet.value = trips
  }
  const clearState = () => {
    positionSet.value = []
    stopSet.value = []
    tripSet.value = []
  }

  return { positionSet, stopSet, tripSet, loading, setRecord, clearState}
})
